<?php
session_start();
require_once("io.php");
require_once("rs.php");
if(ini_set('upload_max_filesize', 20971520)){
}else{
}
	$bucket = "fileshare";
	$file1=explode('.', $_FILES['files']['name']);
	$len=count($file1);
	$key = time().'_caroltc.'.$file1[$len-1];
	$accessKey = '**********';
	$secretKey = '**********';
	
	Qiniu_SetKeys($accessKey, $secretKey);
	
	$putPolicy = new Qiniu_RS_PutPolicy($bucket);
	$upToken = $putPolicy->Token(null);
	$putExtra = new Qiniu_PutExtra();
	$putExtra->Crc32 = 1;
	list($ret, $err) = Qiniu_PutFile($upToken,$key,$_FILES["files"]["tmp_name"], $putExtra);
	if ($err !== null) {

		echo "抱歉，上传失败";
		$_SESSION["UPLOADST"]='N';
		
	} else {
		echo "上传成功";
		$_SESSION["UPLOADNAME"]=$key;
		$_SESSION["UPLOADST"]='Y';
	}
?>